package org.example.realtime.jtp.serv.jtpservicerealtime.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.realtime.jtp.serv.jtpservicerealtime.bean.AppStartCount;
import org.example.realtime.jtp.serv.jtpservicerealtime.bean.KeyCount;
import org.example.realtime.jtp.serv.jtpservicerealtime.bean.TrafficUvReport;

import java.util.List;

/**
 * @Author Lianzy
 * @Package org.example.realtime.jtp.serv.jtpservicerealtime.mapper
 * @Date 2025/5/21 15:45
 */
@Mapper
public interface TrafficChannelStatsMapper {
    /**
     * 获取各渠道独立访客数
     */
@Select("SELECT\n" +
        " channel,\n " +
        " sum(uv_count) as uv_count\n" +
        " FROM jtp_log_report.dws_log_page_view_window_report\n" +
        " WHERE toDate(window_start_time) = #{date}\n" +
        " GROUP BY channel")
    List<TrafficUvReport> selectUvCount(@Param("date")String date);

    @Select("SELECT\n" +
            " keyword,\n " +
            " keyword_count\n" +
            " FROM jtp_log_report.dws_traffic_search_keyword_window_report\n" +
            " WHERE toDate(window_start_time) = #{date}\n")
    List<KeyCount> selectkeycount(@Param("date")String date);
    @Select("select\n" +
            "    count(mid) as start_count,\n" +
            "    count(distinct uid) as start_user_count,\n" +
            "    count(if(is_new = '1', mid, null)) as new_user_count\n" +
            "from jtp_app_log.dwd_traffic_app_start_log\n" +
            "where toDate(toDateTime(ts / 1000)) =#{date}")
    List<AppStartCount> selectstartcount(String date);
}
